package com.company.common.util;


import org.apache.commons.codec.digest.DigestUtils;

public class TokenUtil {

    private static final String key = "Bo_Wo@2020!";

    /**
     * TOKEN 生成规则  userid+token MD5加密
     */
    public static String generateToken(Long userId,Long times)
    {
        String encodeStr= DigestUtils.md5Hex(userId+key+times);
        return encodeStr;
    }

    public static boolean validateToken(String token, Long userId,Long times)
    {
        String key = generateToken(userId,times);

        if (token.equals(key))
        {
            return true;
        }
        return false;
    }
}
